#include<iostream>
//#include<string.h>
#include<stdio.h>
#include<cstring>
using namespace std;
int main()
{
	char str1[31], str2[31];
	char arr[51][27];
	int t;
	//scanf_s("%d", &t);
	cin >> t;
	int k;
	while (t--) {
		//scanf_s("%s%s%d", str1, str2, &k);
		cin >> str1 >> str2 >> k;
		memset(arr, 0, sizeof arr);
		for (int i = 0; str1[i]!=NULL; i++) {
			arr[0][str1[i] - 'a']++;
		}
		for (int i = 0; str1[i] != NULL; i++) {
			arr[1][str2[i] - 'a']++;
		}
		for (int i = 2; i <= k; i++) {
			for (int j = 0; j < 26; j++) {
				arr[i][j] = arr[i - 1][j] + arr[i - 2][j];
			}
		}
		for (int i = 0; i < 26; i++) {
			cout << (char)(i + 'a') << ":" << arr[k][i] << endl;
		}
		cout << endl;
	}
	return 0;
}